﻿(function () {
    oo('class', {
        prop: [
            'rule', 'value',
            { name: 'nullable', value: false }
        ],
        _validator: function (rule, value) {
            this.prop('rule', rule).prop('value', value);
        },
        validate: function () {
            var value = this.prop('value');
            return this.prop('nullable') ? value == null || value == undefined || value.length == 0 :
                new RegExp(this.prop('rule')).test(this.prop('value'));
        }
    });

    oo(':validator', {
        _numberValidator: [
            function (value) { },
            '^\\d+(\.\\d+)?$'
        ]
    });
})();